package com.tsl.exception;

import com.burial.common.result.Result;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/*
* 全局异常处理器
* */
@RestControllerAdvice
public class GlobalExceptionAdvice {
//    @Order(29999)
//    @ExceptionHandler(Exception.class)//捕获全部异常
//    public Result errorAll(Exception exception){
//        exception.printStackTrace();
//        return Result.error("对不起,操作失败,请联系管理员");
//    }
    @Order(1)
    @ExceptionHandler(ProductionException.class)//捕获商品异常
    public Result errorInProduct(ProductionException exception){
        exception.printStackTrace();
        return Result.error(exception.getMessage());
    }
    @Order(1)
    @ExceptionHandler(SelectByIdException.class)//捕获查询异常
    public Result errorInSelectId(ProductionException exception){
        exception.printStackTrace();
        return Result.error(exception.getMessage());
    }
}
